package com.ruoyi.buss.task.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.buss.task.domain.DataTaskExRecordImage;
import com.ruoyi.buss.task.service.IDataTaskExRecordImageService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 营销任务执行记录图片Controller
 * 
 * @author sxy
 * @date 2021-07-16
 */
@RestController
@RequestMapping("/taskRecordImage")
public class DataTaskExRecordImageController extends BaseController
{
    @Autowired
    private IDataTaskExRecordImageService dataTaskExRecordImageService;

    /**
     * 查询营销任务执行记录图片列表
     */
    @PreAuthorize(hasPermi = "buss:taskRecordImage:list")
    @GetMapping("/list")
    public TableDataInfo list(DataTaskExRecordImage dataTaskExRecordImage)
    {
        startPage();
        List<DataTaskExRecordImage> list = dataTaskExRecordImageService.selectDataTaskExRecordImageList(dataTaskExRecordImage);
        return getDataTable(list);
    }

    /**
     * 导出营销任务执行记录图片列表
     */
    @PreAuthorize(hasPermi = "buss:taskRecordImage:export")
    @Log(title = "营销任务执行记录图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataTaskExRecordImage dataTaskExRecordImage) throws IOException
    {
        List<DataTaskExRecordImage> list = dataTaskExRecordImageService.selectDataTaskExRecordImageList(dataTaskExRecordImage);
        ExcelUtil<DataTaskExRecordImage> util = new ExcelUtil<DataTaskExRecordImage>(DataTaskExRecordImage.class);
        util.exportExcel(response, list, "营销任务执行记录图片数据");
    }

    /**
     * 获取营销任务执行记录图片详细信息
     */
    @PreAuthorize(hasPermi = "buss:taskRecordImage:query")
    @GetMapping(value = "/{taskExRecordId}")
    public AjaxResult getInfo(@PathVariable("taskExRecordId") String taskExRecordId)
    {
        return AjaxResult.success(dataTaskExRecordImageService.selectDataTaskExRecordImageById(taskExRecordId));
    }

    /**
     * 新增营销任务执行记录图片
     */
    @PreAuthorize(hasPermi = "buss:taskRecordImage:add")
    @Log(title = "营销任务执行记录图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataTaskExRecordImage dataTaskExRecordImage)
    {
        return toAjax(dataTaskExRecordImageService.insertDataTaskExRecordImage(dataTaskExRecordImage));
    }

    /**
     * 修改营销任务执行记录图片
     */
    @PreAuthorize(hasPermi = "buss:taskRecordImage:edit")
    @Log(title = "营销任务执行记录图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataTaskExRecordImage dataTaskExRecordImage)
    {
        return toAjax(dataTaskExRecordImageService.updateDataTaskExRecordImage(dataTaskExRecordImage));
    }

    /**
     * 删除营销任务执行记录图片
     */
    @PreAuthorize(hasPermi = "buss:taskRecordImage:remove")
    @Log(title = "营销任务执行记录图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{taskExRecordIds}")
    public AjaxResult remove(@PathVariable String[] taskExRecordIds)
    {
        return toAjax(dataTaskExRecordImageService.deleteDataTaskExRecordImageByIds(taskExRecordIds));
    }
}
